all files / lib/ alias.js

100% Statements 15/15
100% Branches 4/4
100% Functions 4/4
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70                                  13×                                                                            
'use strict';
 
/**
 * Module dependencies.
 */
 
var inherit = require('./utils').inherit;
var Facade = require('./facade');
 
/**
 * Initialize a new `Alias` facade with a `dictionary` of arguments.
 *
 * @param {Object} dictionary
 *   @property {string} from
 *   @property {string} to
 *   @property {Object} options
 * @param {Object} opts
 *   @property {boolean|undefined} clone
 */
function Alias(dictionary, opts) {
  Facade.call(this, dictionary, opts);
}
 
/**
 * Inherit from `Facade`.
 */
 
inherit(Alias, Facade);
 
/**
 * Return type of facade.
 *
 * @return {string}
 */
Alias.prototype.action = function() {
  return 'alias';
};
 
Alias.prototype.type = Alias.prototype.action;
 
/**
 * Get `previousId`.
 *
 * @api public
 * @return {*}
 */
Alias.prototype.previousId = function() {
  return this.field('previousId') || this.field('from');
};
 
Alias.prototype.from = Alias.prototype.previousId;
 
/**
 * Get `userId`.
 *
 * @api public
 * @return {string}
 */
Alias.prototype.userId = function() {
  return this.field('userId') || this.field('to');
};
 
Alias.prototype.to = Alias.prototype.userId;
 
/**
 * Exports.
 */
 
module.exports = Alias;